package com.example.park2212.payer

import androidx.lifecycle.MutableLiveData
import com.example.lib_base.entity.PayerBean
import com.example.lib_base.entity.PayerBeanItem
import com.example.lib_base.mvvm.BaseViewModel
import com.example.lib_base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
@HiltViewModel
class PayerViewModel@Inject constructor(val apiService: ApiService):BaseViewModel() {

    val getPayerSuccess = MutableLiveData<PayerBean>()
    fun getPayer(id:Int){
        httpRequest({
            apiService.getPayer(id)
        },getPayerSuccess::postValue)
    }

    val payerDetailSuccess = MutableLiveData<PayerBeanItem>()
    fun getPayerDetail(id:Int){
        httpRequest({
            apiService.payerDetail(id)
        },payerDetailSuccess::postValue)
    }

    val payerAddSuccess = MutableLiveData<PayerBeanItem>()
    fun payerAdd(item: PayerBeanItem){
        httpRequest({
            apiService.payerAdd(mapToBody(item))
        },payerAddSuccess::postValue)

    }
}